package org.catlabs.patterns.jobserver;

import org.catlabs.patterns.jobserver.observer.CurrentConditionsDisplay;
import org.catlabs.patterns.jobserver.observer.StatisticsDisplay;
import org.catlabs.patterns.jobserver.subject.WeatherData;

public class WeatherStation {

	public static void main(String[] args) {

		WeatherData weatherForChicago = new WeatherData();

		new CurrentConditionsDisplay(weatherForChicago);
		new StatisticsDisplay(weatherForChicago);

		weatherForChicago.setMeasurements(getRandomTemp(), getRandomHumidity(),
				getRandomPressure());
		weatherForChicago.setMeasurements(getRandomTemp(), getRandomHumidity(),
				getRandomPressure());
		weatherForChicago.setMeasurements(getRandomTemp(), getRandomHumidity(),
				getRandomPressure());
		weatherForChicago.setMeasurements(getRandomTemp(), getRandomHumidity(),
				getRandomPressure());
		weatherForChicago.setMeasurements(getRandomTemp(), getRandomHumidity(),
				getRandomPressure());

	}

	private static float getRandomTemp() {
		return (float) (Math.random() * 45f);
	}

	private static float getRandomHumidity() {
		return (float) (Math.random() * 100f);
	}

	private static float getRandomPressure() {
		return (float) (Math.random() * 7f);
	}

}
